package com.smag.echarts.service.impl;

import java.math.BigDecimal;
import java.util.List;
import com.smag.common.utils.DateUtils;
import com.smag.echarts.domain.EchartsBarArea;
import com.smag.echarts.domain.vo.EchartsBarAreaYieldVo;
import com.smag.echarts.mapper.EchartsBarAreaMapper;
import com.smag.echarts.service.IEchartsBarAreaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 人均农产总值及耕作面积Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-04-26
 */
@Service
public class EchartsBarAreaServiceImpl implements IEchartsBarAreaService
{
    @Autowired
    private EchartsBarAreaMapper echartsBarAreaMapper;

    /**
     * 查询人均农产总值及耕作面积
     * 
     * @param id 人均农产总值及耕作面积主键
     * @return 人均农产总值及耕作面积
     */
    @Override
    public EchartsBarArea selectEchartsBarAreaById(Long id)
    {
        return echartsBarAreaMapper.selectEchartsBarAreaById(id);
    }

    /**
     * 查询人均农产总值及耕作面积列表
     * 
     * @param echartsBarArea 人均农产总值及耕作面积
     * @return 人均农产总值及耕作面积
     */
    @Override
    public List<EchartsBarArea> selectEchartsBarAreaList(EchartsBarArea echartsBarArea)
    {
        return echartsBarAreaMapper.selectEchartsBarAreaList(echartsBarArea);
    }

    /**
     * 新增人均农产总值及耕作面积
     * 
     * @param echartsBarArea 人均农产总值及耕作面积
     * @return 结果
     */
    @Override
    public int insertEchartsBarArea(EchartsBarArea echartsBarArea)
    {
        echartsBarArea.setCreateTime(DateUtils.getNowDate());
        return echartsBarAreaMapper.insertEchartsBarArea(echartsBarArea);
    }

    /**
     * 修改人均农产总值及耕作面积
     * 
     * @param echartsBarArea 人均农产总值及耕作面积
     * @return 结果
     */
    @Override
    public int updateEchartsBarArea(EchartsBarArea echartsBarArea)
    {
        echartsBarArea.setUpdateTime(DateUtils.getNowDate());
        return echartsBarAreaMapper.updateEchartsBarArea(echartsBarArea);
    }

    /**
     * 批量删除人均农产总值及耕作面积
     * 
     * @param ids 需要删除的人均农产总值及耕作面积主键
     * @return 结果
     */
    @Override
    public int deleteEchartsBarAreaByIds(Long[] ids)
    {
        return echartsBarAreaMapper.deleteEchartsBarAreaByIds(ids);
    }

    /**
     * 删除人均农产总值及耕作面积信息
     * 
     * @param id 人均农产总值及耕作面积主键
     * @return 结果
     */
    @Override
    public int deleteEchartsBarAreaById(Long id)
    {
        return echartsBarAreaMapper.deleteEchartsBarAreaById(id);
    }

    @Override
    public EchartsBarAreaYieldVo firstList() {
        List<String> areas = echartsBarAreaMapper.listAreas();
        List<BigDecimal> values = echartsBarAreaMapper.listValues();
        List<String> years = echartsBarAreaMapper.listYears();
        return new EchartsBarAreaYieldVo(areas, values, years);
    }
}
